package com.cqndt.disaster.device.util;

import java.util.List;

/**
 * 字符串工具类
 *
 * @Author yin_q
 * @Date 2019/6/14 17:57
 * @Email yin_qingqin@163.com
 **/
public class StringTool {

    /**
     * List按指定分隔符转字符串
     * @param list
     * @param separator
     * @return
     */
    public static String listToString(List<?> list, String separator){
        if(list.isEmpty()){
            return "";
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < list.size(); i++) {
            sb.append(list.get(i)).append(separator);
        }
        return sb.toString().substring(0, sb.toString().length() - 1);
    }
}
